package edu.xkd.slice;

import edu.xkd.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;

public class MainAbilitySlice02 extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main_02);


        Button button_02 = (Button) this.findComponentById(ResourceTable.Id_button_02);
        Button button_03 = (Button) this.findComponentById(ResourceTable.Id_button_03);

        //返回
        Button button_back = (Button) this.findComponentById(ResourceTable.Id_button_back);

        button_02.setClickedListener(this::onClickListenerButton02);
        button_03.setClickedListener(this::onClickListenerButtonParams);

        button_back.setClickedListener(this::onClickListenerButtonBack);

    }

    private void onClickListenerButtonParams(Component component) {
        Intent intent = new Intent();
        intent.setParam("name", "李永兴");
        intent.setParam("age", "23");
        this.present(new MainAblitySlice03(), intent);
    }

    private void onClickListenerButton02(Component component) {
    }

    private void onClickListenerButtonBack(Component component) {
        this.terminate();
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
